﻿using Bioinformatics.Types;

namespace Bioinformatics.Utilities
{
    /// <summary>
    /// Provides methods to benchmark class implemented algorithms
    /// </summary>
    public abstract class Benchmarker
    {
        /// <summary>
        /// Get algorithm, the current benchmarker is hooked into.
        /// </summary>
        public IBenchmarkable Algorithm { get; protected set; }

        /// <summary>
        /// Get the current benchmark log.
        /// </summary>
        public BenchmarkLog CurrentBenchmarkLog { get; private set; }

        /// <summary>
        /// Current progress of the benchmark
        /// </summary>
        public int Progress { get; set; }

        /// <summary>
        /// The number of times the benchmark is repeated to ascertain reliable timings
        /// </summary>
        public int Repeat { get; set; }

        /// <summary>
        /// Aborts the current benchmark. Has no effect if not running
        /// </summary>
        public abstract void Abort();

        /// <summary>
        /// Pauses the current benchmark. Has no effect if not running
        /// </summary>
        public abstract void Pause();

        /// <summary>
        /// Resumes a paused benchmark. Has no effect if not running
        /// </summary>
        public abstract void Resume();

        /// <summary>
        /// Asynchronous starting method of the benchmark. Has no effect if running already
        /// </summary>
        public abstract void Start();

        /// <summary>
        /// Stops the current benchmark. Has no effect if not running
        /// </summary>
        public abstract void Stop();

        /// <summary>
        /// Occurs when a running benchmark has completed.
        /// </summary>
        public event BenchmarkCompleteHandler BenchmarkComplete;
    }

    /// <summary>
    /// Represents the method to be called, once the benchmark has completed
    /// </summary>
    /// <param name="sender">The originating benchmarker responsible for raising the event.</param>
    /// <param name="performanceResults">The results produced from the specific instance of the benchmark.</param>
    public delegate void BenchmarkCompleteHandler(Benchmarker sender, BenchmarkLog performanceResults);
}